Skip to content

Conversation

@bjorn3
Copy link
Member

@bjorn3 bjorn3 commented Oct 23, 2025

And if an allocation while printing the backtrace fails, don't try to print another backtrace as that will never succeed.

Split out of #147725 to allow landing this independently of a decision whether or not to remove -Zoom=panic.

@rustbot
Copy link
Collaborator

rustbot commented Oct 23, 2025

The Miri subtree was changed

cc @rust-lang/miri

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Oct 23, 2025
@rustbot
Copy link
Collaborator

rustbot commented Oct 23, 2025

r? @Mark-Simulacrum

rustbot has assigned @Mark-Simulacrum.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@RalfJung
Copy link
Member

Cc @Amanieu @m-ou-se

Copy link
Member

@Mark-Simulacrum Mark-Simulacrum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

r=me with safety comment removed or clarified, if we don't want review from Mara or Amanieu. (Or think this needs libs-api signoff since it's sort of new public feature).

View changes since this review

let mut lock = crate::sys::backtrace::lock();

match crate::panic::get_backtrace_style() {
// SAFETY: we took out a lock just a second ago.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not clear to me what this safety comment is on - I don't see any unsafe code here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was copied from the default panic hook. This comment originates from 1c8f9bb, which doesn't have unsafe code either. cc @jyn514

Copy link
Member

@jyn514 jyn514 Nov 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BacktraceLock::print is incorrectly marked as safe. It and all callers should be marked unsafe. See 1c8f9bb?w=1#diff-1b221b9e32f6143fdd8a5505c8893377e8e9eb1ff47b988716343c7e70393b1bR40.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is it not safe? The mere fact that you have a BacktraceLock (which you need to call print) means that no other thread can be printing a backtrace, right?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh, right. probably the safety comment should just be moved inside that function then?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@Amanieu
Copy link
Member

Amanieu commented Nov 8, 2025

LGTM from the libs side

@bors r=Mark-Simulacrum

@bors
Copy link
Collaborator

bors commented Nov 8, 2025

📌 Commit 91ed7a6 has been approved by Mark-Simulacrum

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Nov 8, 2025
jhpratt added a commit to jhpratt/rust that referenced this pull request Nov 8, 2025
…acrum

Show backtrace on allocation failures when possible

And if an allocation while printing the backtrace fails, don't try to print another backtrace as that will never succeed.

Split out of rust-lang#147725 to allow landing this independently of a decision whether or not to remove `-Zoom=panic`.
bors added a commit that referenced this pull request Nov 8, 2025
Rollup of 15 pull requests

Successful merges:

 - #147404 (Fix issue with callsite inline attribute not being applied sometimes.)
 - #147534 (Implement SIMD funnel shifts in const-eval/Miri)
 - #147686 (update isolate_highest_one for NonZero<T>)
 - #148020 (Show backtrace on allocation failures when possible)
 - #148204 (Modify contributor email entries in .mailmap)
 - #148230 (rustdoc: Properly highlight shebang, frontmatter & weak keywords in source code pages and code blocks)
 - #148555 (Fix rust-by-example spanish translation)
 - #148556 (Fix suggestion for returning async closures)
 - #148585 ([rustdoc] Replace `print` methods with functions to improve code readability)
 - #148600 (re-use `self.get_all_attrs` result for pass indirectly attribute)
 - #148612 (Add note for identifier with attempted hygiene violation)
 - #148613 (Switch hexagon targets to rust-lld)
 - #148644 ([bootstrap] Make `--open` option work with `doc src/tools/error_index_generator`)
 - #148649 (don't completely reset `HeadUsages`)
 - #148675 (Remove eslint-js from npm dependencies)

r? `@ghost`
`@rustbot` modify labels: rollup
jhpratt added a commit to jhpratt/rust that referenced this pull request Nov 8, 2025
…acrum

Show backtrace on allocation failures when possible

And if an allocation while printing the backtrace fails, don't try to print another backtrace as that will never succeed.

Split out of rust-lang#147725 to allow landing this independently of a decision whether or not to remove `-Zoom=panic`.
bors added a commit that referenced this pull request Nov 8, 2025
Rollup of 16 pull requests

Successful merges:

 - #147534 (Implement SIMD funnel shifts in const-eval/Miri)
 - #147686 (update isolate_highest_one for NonZero<T>)
 - #148020 (Show backtrace on allocation failures when possible)
 - #148204 (Modify contributor email entries in .mailmap)
 - #148230 (rustdoc: Properly highlight shebang, frontmatter & weak keywords in source code pages and code blocks)
 - #148279 (rustc_builtin_macros: rename bench parameter to avoid collisions with user-defined function names)
 - #148555 (Fix rust-by-example spanish translation)
 - #148556 (Fix suggestion for returning async closures)
 - #148585 ([rustdoc] Replace `print` methods with functions to improve code readability)
 - #148600 (re-use `self.get_all_attrs` result for pass indirectly attribute)
 - #148612 (Add note for identifier with attempted hygiene violation)
 - #148613 (Switch hexagon targets to rust-lld)
 - #148619 (Enable std locking functions on AIX)
 - #148644 ([bootstrap] Make `--open` option work with `doc src/tools/error_index_generator`)
 - #148649 (don't completely reset `HeadUsages`)
 - #148675 (Remove eslint-js from npm dependencies)

r? `@ghost`
`@rustbot` modify labels: rollup
@Zalathar
Copy link
Member

Zalathar commented Nov 8, 2025

Failed in rollup: #148686 (comment)

@bors r-

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Nov 8, 2025
@bjorn3
Copy link
Member Author

bjorn3 commented Nov 10, 2025

@bors try jobs=aarch64-msvc-1

rust-bors bot added a commit that referenced this pull request Nov 10, 2025
Show backtrace on allocation failures when possible

try-job: aarch64-msvc-1
@rust-bors

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-bors
Copy link

rust-bors bot commented Nov 10, 2025

💔 Test for 3b69a59 failed: CI. Failed jobs:

@rustbot
Copy link
Collaborator

rustbot commented Nov 24, 2025

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@bjorn3
Copy link
Member Author

bjorn3 commented Nov 24, 2025

Added a test ignore for MSVC to match tests/ui/backtrace/backtrace.rs.

@bjorn3 bjorn3 added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Nov 24, 2025
@Mark-Simulacrum
Copy link
Member

r=me with commits squashed

And if an allocation while printing the backtrace fails, don't try to
print another backtrace as that will never succeed.
@bjorn3
Copy link
Member Author

bjorn3 commented Nov 26, 2025

@bors r=Mark-Simulacrum

@bors
Copy link
Collaborator

bors commented Nov 26, 2025

📌 Commit 4627bff has been approved by Mark-Simulacrum

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Nov 26, 2025
bors added a commit that referenced this pull request Nov 26, 2025
Show backtrace on allocation failures when possible

And if an allocation while printing the backtrace fails, don't try to print another backtrace as that will never succeed.

Split out of #147725 to allow landing this independently of a decision whether or not to remove `-Zoom=panic`.
@bors
Copy link
Collaborator

bors commented Nov 26, 2025

⌛ Testing commit 4627bff with merge 91c7271...

@rust-log-analyzer
Copy link
Collaborator

The job i686-msvc-1 failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)
failures:

---- [ui] tests\ui\backtrace\line-tables-only.rs stdout ----

error: test did not exit with success! code=Some(101) so test would pass with `run-fail`
status: exit code: 101
command: PATH="D:\a\rust\rust\build\i686-pc-windows-msvc\stage2\lib\rustlib\i686-pc-windows-msvc\lib;C:\Program Files (x86)\Windows Kits\10\bin\x64;C:\Program Files (x86)\Windows Kits\10\bin\10.0.26100.0\x64;C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.44.35207\bin\HostX64\x64;C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.44.35207\bin\HostX64\x86;D:\a\rust\rust\build\i686-pc-windows-msvc\bootstrap-tools\i686-pc-windows-msvc\release\deps;C:\Program Files\Git\mingw64\bin;C:\Program Files\Git\usr\bin;C:\Users\runneradmin\bin;D:\a\rust\rust\ninja;D:\a\rust\rust\sccache;C:\Program Files\MongoDB\Server\7.0\bin;C:\vcpkg;C:\tools\zstd;C:\hostedtoolcache\windows\stack\3.7.1\x64;C:\cabal\bin;C:\ghcup\bin;C:\mingw64\bin;C:\Program Files\dotnet;C:\Program Files\MySQL\MySQL Server 8.0\bin;C:\Program Files\R\R-4.5.2\bin\x64;C:\SeleniumWebDrivers\GeckoDriver;C:\SeleniumWebDrivers\EdgeDriver;C:\SeleniumWebDrivers\ChromeDriver;C:\Program Files (x86)\sbt\bin;C:\Program Files (x86)\GitHub CLI;C:\Program Files\Git\usr\bin;C:\Program Files (x86)\pipx_bin;C:\npm\prefix;C:\hostedtoolcache\windows\go\1.24.9\x64\bin;C:\hostedtoolcache\windows\Python\3.9.13\x64\Scripts;C:\hostedtoolcache\windows\Python\3.9.13\x64;C:\hostedtoolcache\windows\Ruby\3.3.10\x64\bin;C:\Program Files\OpenSSL\bin;C:\tools\kotlinc\bin;C:\hostedtoolcache\windows\Java_Temurin-Hotspot_jdk\17.0.17-10\x64\bin;C:\Program Files\ImageMagick-7.1.2-Q16-HDRI;C:\Program Files\Microsoft SDKs\Azure\CLI2\wbin;C:\ProgramData\kind;C:\ProgramData\Chocolatey\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0;C:\Windows\System32\OpenSSH;C:\Program Files\PowerShell\7;C:\Program Files\Microsoft\Web Platform Installer;C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\170\Tools\Binn;C:\Program Files\Microsoft SQL Server\150\Tools\Binn;C:\Program Files\dotnet;C:\Program Files (x86)\Windows Kits\10\Windows Performance Toolkit;C:\Program Files (x86)\WiX Toolset v3.14\bin;C:\Program Files\Microsoft SQL Server\130\DTS\Binn;C:\Program Files\Microsoft SQL Server\140\DTS\Binn;C:\Program Files\Microsoft SQL Server\150\DTS\Binn;C:\Program Files\Microsoft SQL Server\160\DTS\Binn;C:\Program Files\Microsoft SQL Server\170\DTS\Binn;C:\ProgramData\chocolatey\lib\pulumi\tools\Pulumi\bin;C:\Program Files\CMake\bin;C:\Strawberry\c\bin;C:\Strawberry\perl\site\bin;C:\Strawberry\perl\bin;C:\ProgramData\chocolatey\lib\maven\apache-maven-3.9.11\bin;C:\Program Files\Microsoft Service Fabric\bin\Fabric\Fabric.Code;C:\Program Files\Microsoft SDKs\Service Fabric\Tools\ServiceFabricLocalClusterManager;C:\Program Files\nodejs;C:\Program Files\Git\cmd;C:\Program Files\Git\mingw64\bin;C:\Program Files\Git\usr\bin;C:\Program Files\GitHub CLI;C:\tools\php;C:\Program Files (x86)\sbt\bin;C:\Program Files\Amazon\AWSCLIV2;C:\Program Files\Amazon\SessionManagerPlugin\bin;C:\Program Files\Amazon\AWSSAMCLI\bin;C:\Program Files\Microsoft SQL Server\130\Tools\Binn;C:\Program Files\mongosh;C:\Program Files\LLVM\bin;C:\Program Files (x86)\LLVM\bin;C:\Users\runneradmin\.dotnet\tools;C:\Users\runneradmin\.cargo\bin;C:\Users\runneradmin\AppData\Local\Microsoft\WindowsApps;C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.44.35207\bin\HostX64\x86" "D:\\a\\rust\\rust\\build\\i686-pc-windows-msvc\\test\\ui\\backtrace\\line-tables-only\\a.exe"
stdout: none
--- stderr -------------------------------
Backtrace [
    { fn: "<std::backtrace::Backtrace>::capture" },
    { fn: "line_tables_only_helper::capture_backtrace::closure$0", file: "D:\a\rust\rust\tests\ui\backtrace\auxiliary\line-tables-only-helper.rs", line: 20 },
    { fn: "line_tables_only_helper::baz<line_tables_only_helper::capture_backtrace::closure_env$0>", file: "D:\a\rust\rust\tests\ui\backtrace\auxiliary\line-tables-only-helper.rs", line: 5 },
    { fn: "line_tables_only_helper::bar<line_tables_only_helper::capture_backtrace::closure_env$0>", file: "D:\a\rust\rust\tests\ui\backtrace\auxiliary\line-tables-only-helper.rs", line: 10 },
    { fn: "line_tables_only::main", file: "D:\a\rust\rust\tests\ui\backtrace\line-tables-only.rs", line: 44 },
    { fn: "line_tables_only::main", file: "D:\a\rust\rust\tests\ui\backtrace\line-tables-only.rs", line: 44 },
    { fn: "core::ops::function::FnOnce::call_once", file: "/rustc/FAKE_PREFIX\library\core\src\ops\function.rs", line: 250 },
    { fn: "std::sys::backtrace::__rust_begin_short_backtrace<void (*)(),tuple$<> >", file: "/rustc/FAKE_PREFIX\library\std\src\sys\backtrace.rs", line: 160 },
    { fn: "std::rt::lang_start::closure$0", file: "/rustc/FAKE_PREFIX\library\std\src\rt.rs", line: 206 },
    { fn: "core::ops::function::FnOnce::call_once", file: "/rustc/FAKE_PREFIX\library\core\src\ops\function.rs", line: 250 },
    { fn: "core::ops::function::FnOnce::call_once<std::rt::lang_start::closure_env$0<tuple$<> >,tuple$<> >", file: "/rustc/FAKE_PREFIX\library\std\src\rt.rs", line: 206 },
    { fn: "std::rt::lang_start_internal" },
    { fn: "main" },
    { fn: "BaseThreadInitThunk" },
    { fn: "RtlInitializeExceptionChain" },
    { fn: "RtlGetAppContainerNamedObjectPath" },
]
Backtrace [
    { fn: "<std::backtrace::Backtrace>::capture" },
    { fn: "line_tables_only_helper::capture_backtrace::closure$0", file: "D:\a\rust\rust\tests\ui\backtrace\auxiliary\line-tables-only-helper.rs", line: 20 },
    { fn: "line_tables_only_helper::baz<line_tables_only_helper::capture_backtrace::closure_env$0>", file: "D:\a\rust\rust\tests\ui\backtrace\auxiliary\line-tables-only-helper.rs", line: 5 },
    { fn: "line_tables_only_helper::bar<line_tables_only_helper::capture_backtrace::closure_env$0>", file: "D:\a\rust\rust\tests\ui\backtrace\auxiliary\line-tables-only-helper.rs", line: 10 },
    { fn: "line_tables_only::main", file: "D:\a\rust\rust\tests\ui\backtrace\line-tables-only.rs", line: 44 },
    { fn: "line_tables_only::main", file: "D:\a\rust\rust\tests\ui\backtrace\line-tables-only.rs", line: 44 },
    { fn: "core::ops::function::FnOnce::call_once", file: "/rustc/FAKE_PREFIX\library\core\src\ops\function.rs", line: 250 },
    { fn: "std::sys::backtrace::__rust_begin_short_backtrace<void (*)(),tuple$<> >", file: "/rustc/FAKE_PREFIX\library\std\src\sys\backtrace.rs", line: 160 },
    { fn: "std::rt::lang_start::closure$0", file: "/rustc/FAKE_PREFIX\library\std\src\rt.rs", line: 206 },
    { fn: "core::ops::function::FnOnce::call_once", file: "/rustc/FAKE_PREFIX\library\core\src\ops\function.rs", line: 250 },
    { fn: "core::ops::function::FnOnce::call_once<std::rt::lang_start::closure_env$0<tuple$<> >,tuple$<> >", file: "/rustc/FAKE_PREFIX\library\std\src\rt.rs", line: 206 },
    { fn: "std::rt::lang_start_internal" },
    { fn: "main" },
    { fn: "BaseThreadInitThunk" },
    { fn: "RtlInitializeExceptionChain" },
    { fn: "RtlGetAppContainerNamedObjectPath" },
]

thread 'main' (1540) panicked at D:\a\rust\rust\tests\ui\backtrace\line-tables-only.rs:39:5:
backtrace does not contain expected line 15
stack backtrace:
---

Some tests failed in compiletest suite=ui mode=ui host=i686-pc-windows-msvc target=i686-pc-windows-msvc
Bootstrap failed while executing `test --stage 2 --skip=compiler --skip=src`
Build completed unsuccessfully in 1:48:46
make: *** [Makefile:112: ci-msvc-py] Error 1
  local time: Wed Nov 26 23:28:41 CUT 2025
  network time: Wed, 26 Nov 2025 23:28:42 GMT
##[error]Process completed with exit code 2.
##[group]Run echo "disk usage:"
echo "disk usage:"

@bors
Copy link
Collaborator

bors commented Nov 26, 2025

💔 Test failed - checks-actions

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Nov 26, 2025
The content of the baz function has always been on line 5, not line 15.
Presumably it previously accidentally worked as the call in the foo
function is on line 15, but now it likely tail calls to bar.
@bjorn3
Copy link
Member Author

bjorn3 commented Nov 27, 2025

Fixed a test that seems like it happened to work by accident before.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants